/**
 *
 */
package anysware.source.resource;

import net.sf.json.JsonConfig;

import org.apache.commons.lang.NotImplementedException;
import org.restlet.data.MediaType;
import org.restlet.resource.Representation;
import org.restlet.resource.Variant;

import anysware.restlet.JSONRepresentation;
import anysware.restlet.RepresentationHandler;

/**
 * TODO: doc me
 *
 * @author keke<keke@codehaus.org>
 * @revision $Revision: 111 $
 * @version
 */
public class SourcesRepresentationHandler implements RepresentationHandler {
	private JsonConfig	jsonConfig;

	/**
	 * @param jsonConfig
	 *            the jsonConfig to set
	 */
	public void setJsonConfig(final JsonConfig jsonConfig) {
		this.jsonConfig = jsonConfig;
	}

	public Object toEntity(final Representation representation) {
		throw new NotImplementedException();
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see anysware.restlet.RepresentationHandler#toRepresentation(java.lang.Object,
	 *      org.restlet.resource.Variant)
	 */
	public Representation toRepresentation(final Object entity,
	        final Variant variant) {
		final MediaType mediaType = variant.getMediaType();
		if (mediaType.equals(MediaType.APPLICATION_JSON, true)) {
			return new JSONRepresentation(entity, jsonConfig, mediaType);
		}
		return null;
	}

}
